using Android.Content;
using CometServiceDemo.Comet;

namespace CometServiceDemo.LocalComunication
{
    public delegate void OnReceiveBroadcastDelegate(BroadcastReceiveEventArgs args);

    public class CommonBroadcastReceive : BroadcastReceiver
    {
        public event OnReceiveBroadcastDelegate OnReceiveBroadcast;

        public override void OnReceive(Context context, Intent intent)
        {
            var result = intent.Extras.GetString(intent.Action);
            if (OnReceiveBroadcast != null)
            {
                OnReceiveBroadcast(new BroadcastReceiveEventArgs()
                    {ReceiveMessageType = intent.Action, ReceiveData = result});
            }
        }
    }
}